//
//  BHUserFunApplyDetailModel.swift
//  BigHealth
//
//  Created by 蔺百好 on 2021/8/18.
//

import UIKit

class BHUserFunApplyDetailModel: NSObject {
    var funId: String = ""
    var name: String = ""
    var cityName: String = ""
    var areaName: String = ""
    var distance: String = ""
    var beginTime: String = ""
    var signupEndTime: String = ""
    var venueName: String = ""
    var venueId: String = ""
    var longitude: String = ""
    var latitude: String = ""
    var price: String = ""
    var typeOneLabel: String = ""
    var typeTwoLabel: String = ""
    var remarks: String = ""
    var cover: String = ""
    var launchUserId: String = ""
    var launchUserName: String = ""
    var launchAvatar: String = ""
    var introduce: String = ""
    
    var contactNumber: String = ""
    var signupId: String = ""
    var signupTime: String = ""
    var signUserId: String = ""
    var signUserPhone: String = ""
    
    
    var signUserName: String = ""
    var orderCode: String = ""
    var payTime: String = ""
    
    
    var collectionFlag: Int = 0
    var ifFee: Int = 0 // 是否需要报名费 1是 0否
    var payType: Int = 0 // 付款类型 1:支付宝 2:微信 登录人为报名人员
    
    var signUserArray: [BHFunApplyUserModel] = []
    
    
    func parseDic(_ dic: [String:Any])  {
        self.funId = BHJsonTool.decodeStringFromDic(dic: dic, key: "id")
        self.name = BHJsonTool.decodeStringFromDic(dic: dic, key: "name")
        self.cityName = BHJsonTool.decodeStringFromDic(dic: dic, key: "cityName")
        self.areaName = BHJsonTool.decodeStringFromDic(dic: dic, key: "areaName")
        self.distance = BHJsonTool.decodeStringFromDic(dic: dic, key: "distance")
        self.beginTime = BHJsonTool.decodeStringFromDic(dic: dic, key: "beginTime")
        self.signupEndTime = BHJsonTool.decodeStringFromDic(dic: dic, key: "signupEndTime")
        self.venueName = BHJsonTool.decodeStringFromDic(dic: dic, key: "venueName")
        self.venueId = BHJsonTool.decodeStringFromDic(dic: dic, key: "venueId")
        self.longitude = BHJsonTool.decodeStringFromDic(dic: dic, key: "longitude")
        self.latitude = BHJsonTool.decodeStringFromDic(dic: dic, key: "latitude")
        self.price = BHJsonTool.decodeStringFromDic(dic: dic, key: "price")
        self.typeOneLabel = BHJsonTool.decodeStringFromDic(dic: dic, key: "typeOneLabel")
        self.typeTwoLabel = BHJsonTool.decodeStringFromDic(dic: dic, key: "typeTwoLabel")
        self.remarks = BHJsonTool.decodeStringFromDic(dic: dic, key: "remarks")
        self.cover = BHJsonTool.decodeStringFromDic(dic: dic, key: "cover")
        self.launchUserId = BHJsonTool.decodeStringFromDic(dic: dic, key: "launchUserId")
        self.launchUserName = BHJsonTool.decodeStringFromDic(dic: dic, key: "launchUserName")
        self.launchAvatar = BHJsonTool.decodeStringFromDic(dic: dic, key: "launchAvatar")
        self.introduce = BHJsonTool.decodeStringFromDic(dic: dic, key: "introduce")
        self.contactNumber = BHJsonTool.decodeStringFromDic(dic: dic, key: "contactNumber")
        self.signupId = BHJsonTool.decodeStringFromDic(dic: dic, key: "signupId")
        self.signupTime = BHJsonTool.decodeStringFromDic(dic: dic, key: "signupTime")
        self.signUserId = BHJsonTool.decodeStringFromDic(dic: dic, key: "signUserId")
        self.signUserName = BHJsonTool.decodeStringFromDic(dic: dic, key: "signUserName")
        self.orderCode = BHJsonTool.decodeStringFromDic(dic: dic, key: "orderCode")
        self.payTime = BHJsonTool.decodeStringFromDic(dic: dic, key: "payTime")
        self.signUserPhone = BHJsonTool.decodeStringFromDic(dic: dic, key: "signUserPhone")
        
        self.collectionFlag = BHJsonTool.decodeIntFromDic(dic: dic, key: "collectionFlag")
        self.ifFee = BHJsonTool.decodeIntFromDic(dic: dic, key: "ifFee")
        self.payType = BHJsonTool.decodeIntFromDic(dic: dic, key: "payType")

        let array = BHJsonTool.decodeArrayFromDic(dic: dic, key: "signList")
        if self.signUserArray.count != 0 {
            self.signUserArray.removeAll()
        }
        
        for item in array {
            if item is NSNull {
                
            }else {
                let model = BHFunApplyUserModel.init()
                model.parseDic(item as! [String:Any])
                self.signUserArray.append(model)
            }
        }
        
        if self.price.isEmpty == true {
            self.price = "0"
        }
    }
}

class BHFunApplyUserModel {
    var userId: String = ""
    var userName: String = ""
    var signName: String = ""
    var userAvatar: String = ""
    var userPhone: String = ""
    var signPhone: String = ""
    
    func parseDic(_ dic: [String:Any])  {
        self.userId = BHJsonTool.decodeStringFromDic(dic: dic, key: "userId")
        self.userName = BHJsonTool.decodeStringFromDic(dic: dic, key: "userName")
        self.signName = BHJsonTool.decodeStringFromDic(dic: dic, key: "signName")
        self.userAvatar = BHJsonTool.decodeStringFromDic(dic: dic, key: "userAvatar")
        self.userPhone = BHJsonTool.decodeStringFromDic(dic: dic, key: "userPhone")
        self.signPhone = BHJsonTool.decodeStringFromDic(dic: dic, key: "signPhone")
    }
}
